package com.ubxtech.mqtt.service;

import java.util.Map;

/**
 * 注意要在Boot启动类中加  @IntegrationComponentScan(basePackages = {"com.ubxtech"})
 * https://blog.csdn.net/kumubajie/article/details/122939003
 *
 * 整合多mqtt连接,自己实现发送消息的功能,注释掉 @MessagingGateway(defaultRequestChannel = "mqttOutboundChannel")
 * @author Victor.Xiao
 * @since 2022-03-29 15:51
*/
public interface MqttGateway {

    /**
     * 发送消息,默认给第一个客户端发消息
     * @author Victor.Xiao
     * @since 2022-11-10 11:22
     * @param topic topic
     * @param payload payload
    */
    void sendToMqtt(String topic, String payload);

    /**
     * 发送消息,默认给第一个客户端发消息
     * @author Victor.Xiao
     * @since 2022-11-10 11:22
     * @param topic topic
     * @param qos qos
     * @param retain retain
     * @param payload payload
    */
    void sendToMqtt(String topic, int qos,boolean retain, String payload);


    /**
     * 发送消息
     * @author Victor.Xiao
     * @since 2022-11-10 11:38
     * @param channel 根据配置文件传名称
     * @param topic topic
     * @param payload payload
    */
    void sendToMqtt(String channel, String topic, String payload);

    /**
     * 发送消息
     * @author Victor.Xiao
     * @since 2022-11-10 11:22
     * @param channel 根据配置文件传名称
     * @param topic topic
     * @param qos qos
     * @param retain retain
     * @param payload payload
     */
    void sendToMqtt(String channel, String topic, int qos,boolean retain, String payload);

    /**
     * 发送消息 默认QOS:1 retain:false,MqttHeaders.MESSAGE_EXPIRY_INTERVAL 过期消息
     * @author Victor.Xiao
     * @since 2024-05-31 14:51
     * @param channel channel
     * @param topic topic
     * @param payload payload
     * @param headers key为org.springframework.integration.mqtt.support.MqttHeaders中的值
    */
    void sendToMqtt(String channel , String topic, String payload, Map<String,String> headers);

    /**
     * 发送消息 默认QOS:1 retain:false,MqttHeaders.MESSAGE_EXPIRY_INTERVAL 过期消息
     * @author Victor.Xiao
     * @since 2024-05-31 14:51
     * @param topic topic
     * @param payload payload
     * @param headers key为org.springframework.integration.mqtt.support.MqttHeaders中的值
     */
    void sendToMqtt(String topic, String payload, Map<String,String> headers);
}
